package com.glodon.wps.controller;

import com.glodon.wps.constant.Constants;
import com.glodon.wps.vo.CallbackDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Title:
 * @Description:
 * @author: Haijun
 * @emial: isaiah@sohu.com
 * @date 2021/10/1809:30
 */
@Controller
@RequestMapping("/cps")
@Slf4j
public class CpsController {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @RequestMapping("/callback")
    public String callback(@RequestBody  CallbackDataVO callbackDataVO){
        log.info("接收到回调参数{}：" , callbackDataVO);


        long endTime = System.currentTimeMillis();
        log.info("调用格式转换接口：回调成功后当前时间{}", endTime);
        ValueOperations<String, String> stringStringValueOperations = redisTemplate.opsForValue();
        String startTimeStr = stringStringValueOperations.get(Constants.SEND_WPS_CONVERT_TIME);
        long startTime = Long.parseLong(startTimeStr);
        Long constSecondTime = (endTime  - startTime) ;

        log.info("一次转换所花费的时间{}ms：" ,constSecondTime);




        return "success";

    }

}
